package br.unisinos.tetris.command;

import br.unisinos.tetris.engine.Controller;
import br.unisinos.tetris.pieces.Piece;
import br.unisinos.tetris.state.PieceState;
import br.unisinos.tetris.view.TetrisApp;
import br.unisinos.tetris.view.TetrisView;


public class RotateCommand implements Command {

	@Override
	public void run() {
		Controller c = Controller.getInstance();
		PieceState state = c.getCurrentPiece();
		state = state.getNextState();
		c.setCurrentPiece(state);
		
		Piece piece = state.getPiece();
		piece.setX(piece.getX() - 10);
		TetrisView view = (TetrisView) TetrisApp.getApplication().getMainView();
		state.paint(view.getMainPanel());
		view.getMainPanel().repaint();
	}

}
